/*
 * Copyright 2008-2009 Nobject.org, All Rights Reserved.
 * 
 * This software is licensed under LGPL license.
 * See terms of license at gnu.org.
 * 
 * For more information,visit:
 * 
 * http://www.nobject.org
 */
package org.nobject.common.code.model.javascript;

/**
 * Variable Model class
 * 
 * @author bianrongjun
 * @version 1.0
 */
public class VariableModel {

	/**
	 * Variable Name
	 */
	private String variableName;

	/**
	 * Variable Type
	 */
	private String variableType;

	/**
	 * Variable Comment
	 */
	private String variableComment;

	/**
	 * Variable DefaultValue
	 */
	private String variableDefaultValue;

	/**
	 * Constructor
	 */
	public VariableModel() {

	}

	/**
	 * Constructor
	 * 
	 * @param variableName
	 */
	public VariableModel(String variableName) {
		this.variableName = variableName;
	}

	/**
	 * Constructor
	 * 
	 * @param variableName
	 * @param variableDefaultValue
	 * @param variableComment
	 */
	public VariableModel(String variableName, String variableDefaultValue, String variableComment) {
		this.variableName = variableName;
		this.variableDefaultValue = variableDefaultValue;
		this.variableComment = variableComment;
	}

	/**
	 * Set Variable Name
	 * 
	 * @param variableName
	 */
	public void setVariableName(String variableName) {
		this.variableName = variableName;
	}

	/**
	 * Set Variable Type
	 * 
	 * @param variableType
	 */
	public void setVariableType(String variableType) {
		this.variableType = variableType;
	}

	/**
	 * Set Variable Comment
	 * 
	 * @param variableComment
	 */
	public void setVariableComment(String variableComment) {
		this.variableComment = variableComment;
	}

	/**
	 * Get Variable Name
	 * 
	 * @return
	 */
	public String getVariableName() {
		return variableName;
	}

	/**
	 * Get Variable Type
	 * 
	 * @return
	 */
	public String getVariableType() {
		return variableType;
	}

	/**
	 * Get Variable Comment
	 * 
	 * @return
	 */
	public String getVariableComment() {
		return variableComment;
	}

	/**
	 * Get Variable Default Value
	 * 
	 * @return
	 */
	public String getVariableDefaultValue() {
		return variableDefaultValue;
	}

	/**
	 * Set Variable Default Value
	 * 
	 * @param variableDefaultValue
	 */
	public void setVariableDefaultValue(String variableDefaultValue) {
		this.variableDefaultValue = variableDefaultValue;
	}

	/**
	 * Check
	 * 
	 * @return
	 */
	public boolean check() {
		if (variableName != null && !variableName.equals("")) {
			return true;
		} else {
			return false;
		}
	}

	/**
	 * Generate Variable String
	 * 
	 * @return
	 */
	public String generateVariableString() {
		StringBuffer sb = new StringBuffer();
		sb.append("var " + this.getVariableName() + ((this.getVariableDefaultValue() != null) ? ("=" + this.getVariableDefaultValue()) : "") + ";" + ((this.getVariableComment() != null) ? ("//" + this.getVariableComment()) : ""));
		return sb.toString();
	}

}
